package dataformat

import (
	"strings"

	v10 "github.com/go-playground/validator/v10"
)

func IsEmail(emailStr string) bool {
	idx := strings.Index(emailStr, "@")
	if (idx == -1) || (idx == 0) || (idx == len(emailStr)-1) {
		return false
	}

	if idx > 64 || len(emailStr)-idx > 255 {
		return false
	}

	validator := v10.New()
	return validator.Var(emailStr, "email") == nil
}
